\hypertarget{String_8h}{
\section{Source/String.h File Reference}
\label{String_8h}\index{Source/String.h@{Source/String.h}}
}
A library to handle C strings easily.  


{\tt \#include $<$stdio.h$>$}\par
{\tt \#include $<$stdlib.h$>$}\par
{\tt \#include $<$string.h$>$}\par
{\tt \#include $<$ctype.h$>$}\par
{\tt \#include $<$math.h$>$}\par


Include dependency graph for String.h:\nopagebreak
\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=168pt]{String_8h__incl}
\end{center}
\end{figure}


This graph shows which files directly or indirectly include this file:\nopagebreak
\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=237pt]{String_8h__dep__incl}
\end{center}
\end{figure}
\subsection*{Data Structures}
\begin{CompactItemize}
\item 
struct \hyperlink{structS__String}{S\_\-String}
\begin{CompactList}\small\item\em A structure to hold the string, and details about it. Should always be used as a pointer with the functions. \item\end{CompactList}\end{CompactItemize}
\subsection*{Defines}
\begin{CompactItemize}
\item 
\#define \hyperlink{String_8h_0563d6c3e3ffc508c38137a212cdcc38}{S\_\-GetCString}(Str)~(((char $\ast$)((\hyperlink{structS__String}{S\_\-String} $\ast$)Str) $\rightarrow$ String))
\item 
\#define \hyperlink{String_8h_c0d7369f7433d6984f0b888fefd524a9}{S\_\-GetStringLength}(String)~((((\hyperlink{structS__String}{S\_\-String}$\ast$)String) $\rightarrow$ Length))
\item 
\#define \hyperlink{String_8h_76fecf032417987ff2a52d09cadc74fe}{S\_\-Print}(Str)~(printf(\char`\"{}\%s\char`\"{}, (((S\_\-String $\ast$)Str) $\rightarrow$ String)))
\item 
\#define \hyperlink{String_8h_1bf2e5f197b170b1c56d22bda138dd41}{S\_\-GetSize}(Str)~(((\hyperlink{structS__String}{S\_\-String} $\ast$)Str) $\rightarrow$ Size)
\item 
\#define \hyperlink{String_8h_cf8d6deb7696df87d92f7b321afee568}{S\_\-At}(Str, At)~(char)(((\hyperlink{structS__String}{S\_\-String} $\ast$)Str) $\rightarrow$ String\mbox{[}At\mbox{]})
\item 
\#define \hyperlink{String_8h_eb0ec9f2dbaa8a1504bee0ce980db6e1}{S\_\-Capitalise}(Str)
\end{CompactItemize}
\subsection*{Functions}
\begin{CompactItemize}
\item 
\hyperlink{structS__String}{S\_\-String} $\ast$ \hyperlink{String_8h_7dc0082e7024328d845f6303022d3a3d}{S\_\-NewString} (char $\ast$String)
\item 
\hyperlink{structS__String}{S\_\-String} $\ast$ \hyperlink{String_8h_302e8ec221992e858d038c99cfd85d96}{S\_\-NewStringSafe} (char $\ast$String, int Length)
\item 
void \hyperlink{String_8h_fb479750a3d46abcbe6687f10cf48d93}{S\_\-FreeString} (\hyperlink{structS__String}{S\_\-String} $\ast$String)
\item 
int \hyperlink{String_8h_397b9f358bf019dc5e336404c7ec5ff7}{S\_\-SetString} (\hyperlink{structS__String}{S\_\-String} $\ast$String, char $\ast$Str)
\item 
int \hyperlink{String_8h_5ab90ac0b5817203509ad74809e24c81}{S\_\-SetStringS} (\hyperlink{structS__String}{S\_\-String} $\ast$String, \hyperlink{structS__String}{S\_\-String} $\ast$SetString)
\item 
int \hyperlink{String_8h_7e2d8dace30f0de44d7b27671477a989}{S\_\-SetStringSafe} (\hyperlink{structS__String}{S\_\-String} $\ast$String, char $\ast$Str, int Length)
\item 
int \hyperlink{String_8h_2f497e9820c3ef3262b2b79c67de1e30}{S\_\-AppendString} (\hyperlink{structS__String}{S\_\-String} $\ast$String, char $\ast$Str)
\item 
int \hyperlink{String_8h_25e94b51b04d73fdb76771ea78af38eb}{S\_\-AppendStringS} (\hyperlink{structS__String}{S\_\-String} $\ast$Str, \hyperlink{structS__String}{S\_\-String} $\ast$AppendString)
\item 
int \hyperlink{String_8h_e90bcfd70b2bf03e0c4c440dd3c06155}{S\_\-AppendStringSafe} (\hyperlink{structS__String}{S\_\-String} $\ast$String, char $\ast$Str, int Length)
\item 
int \hyperlink{String_8h_e350e958b6a6cf2295e9df849c90b5bd}{S\_\-InsertString} (\hyperlink{structS__String}{S\_\-String} $\ast$String, int Offset, char $\ast$Str)
\item 
int \hyperlink{String_8h_4b914eef05daab599aaf9e0cb7e1fd8b}{S\_\-InsertStringS} (\hyperlink{structS__String}{S\_\-String} $\ast$Str, int Offset, \hyperlink{structS__String}{S\_\-String} $\ast$InsertString)
\item 
int \hyperlink{String_8h_2e7248a6c3ab64367a1ebe42945e9357}{S\_\-InsertStringSafe} (\hyperlink{structS__String}{S\_\-String} $\ast$String, int Offset, char $\ast$Str, int Length)
\item 
void \hyperlink{String_8h_dba46a32cd273e7b883a2620add35c12}{S\_\-PrintSafe} (\hyperlink{structS__String}{S\_\-String} $\ast$String)
\item 
int \hyperlink{String_8h_feffcc4d51463b7d5e0ee8f909281c20}{S\_\-PrependString} (\hyperlink{structS__String}{S\_\-String} $\ast$String, char $\ast$Str)
\item 
int \hyperlink{String_8h_377ac91d577be4a74ff215cdf1acb1b6}{S\_\-PrependStringS} (\hyperlink{structS__String}{S\_\-String} $\ast$String, \hyperlink{structS__String}{S\_\-String} $\ast$PString)
\item 
int \hyperlink{String_8h_f565622e62f5b2e68b3dadaa9e81357d}{S\_\-PrependStringSafe} (\hyperlink{structS__String}{S\_\-String} $\ast$String, char $\ast$Str, int Length)
\item 
int \hyperlink{String_8h_a18276a7c0d108c9f111888a7e5516ac}{S\_\-SetSize} (\hyperlink{structS__String}{S\_\-String} $\ast$String, int Size)
\item 
\hypertarget{String_8h_43a55612a538eedf1dd56b8789abbf4e}{
int \textbf{S\_\-FindFirstC} (\hyperlink{structS__String}{S\_\-String} $\ast$String, char Search)}
\label{String_8h_43a55612a538eedf1dd56b8789abbf4e}

\item 
\hypertarget{String_8h_7060a395c2492e909d32bda066c68fe5}{
int \textbf{S\_\-FindLastC} (\hyperlink{structS__String}{S\_\-String} $\ast$String, char Search)}
\label{String_8h_7060a395c2492e909d32bda066c68fe5}

\item 
\hypertarget{String_8h_251875b17a6cd6dd1b68f5ccffb148c7}{
int \textbf{S\_\-FindFirst} (\hyperlink{structS__String}{S\_\-String} $\ast$String, char $\ast$Search)}
\label{String_8h_251875b17a6cd6dd1b68f5ccffb148c7}

\item 
\hypertarget{String_8h_cca59ac26554e0404091bde4b99c1560}{
int \textbf{S\_\-FindLast} (\hyperlink{structS__String}{S\_\-String} $\ast$String, char $\ast$Search)}
\label{String_8h_cca59ac26554e0404091bde4b99c1560}

\item 
\hypertarget{String_8h_4b8d4a3120aac7d882997459d3b40f1d}{
int \textbf{S\_\-FindFirstS} (\hyperlink{structS__String}{S\_\-String} $\ast$String, \hyperlink{structS__String}{S\_\-String} $\ast$Search)}
\label{String_8h_4b8d4a3120aac7d882997459d3b40f1d}

\item 
\hypertarget{String_8h_9eeaba93a0cd17cf83c50bbb4f49089a}{
int \textbf{S\_\-FindLastS} (\hyperlink{structS__String}{S\_\-String} $\ast$String, \hyperlink{structS__String}{S\_\-String} $\ast$Search)}
\label{String_8h_9eeaba93a0cd17cf83c50bbb4f49089a}

\item 
\hypertarget{String_8h_c3e06a7643b7a69236f9d83d1e7b83f6}{
int \textbf{S\_\-FindFirstSafe} (\hyperlink{structS__String}{S\_\-String} $\ast$String, char $\ast$Search, int Length)}
\label{String_8h_c3e06a7643b7a69236f9d83d1e7b83f6}

\item 
\hypertarget{String_8h_85c86b4e3ab9e5c96e3a07f69bb347fd}{
int \textbf{S\_\-FindLastSafe} (\hyperlink{structS__String}{S\_\-String} $\ast$String, char $\ast$Search, int Length)}
\label{String_8h_85c86b4e3ab9e5c96e3a07f69bb347fd}

\item 
void \hyperlink{String_8h_c1a935af70a79d84f2358d693a669afe}{S\_\-StringReverse} (\hyperlink{structS__String}{S\_\-String} $\ast$String)
\item 
void \hyperlink{String_8h_251e3dc54d4e92739f21cc1f2a9c39d4}{S\_\-ToUpper} (\hyperlink{structS__String}{S\_\-String} $\ast$String)
\item 
void \hyperlink{String_8h_b493e8c1abbeff2ebcb678c99e558dae}{S\_\-Strip} (\hyperlink{structS__String}{S\_\-String} $\ast$String)
\item 
int \hyperlink{String_8h_2033f8307c67c28af946922073dc46bf}{S\_\-PadFront} (\hyperlink{structS__String}{S\_\-String} $\ast$Str, int Length, char PadChar)
\item 
int \hyperlink{String_8h_ec9f3e49d886b5bb88dd74d378466ee7}{S\_\-ToInt} (\hyperlink{structS__String}{S\_\-String} $\ast$String)
\item 
long \hyperlink{String_8h_06727de884a78f7eefdbd8c8c5e0f3ea}{S\_\-ToLong} (\hyperlink{structS__String}{S\_\-String} $\ast$String)
\item 
double \hyperlink{String_8h_dcdee4e175553bec6a8e6ebea86d952b}{S\_\-ToDouble} (\hyperlink{structS__String}{S\_\-String} $\ast$String)
\item 
\hypertarget{String_8h_0db231f9a618f37d0c97c26e99b4b494}{
float \textbf{S\_\-ToFloat} (\hyperlink{structS__String}{S\_\-String} $\ast$String)}
\label{String_8h_0db231f9a618f37d0c97c26e99b4b494}

\item 
\hypertarget{String_8h_d9f08c3a7df7a114b92ced900f34fd12}{
\hyperlink{structS__String}{S\_\-String} $\ast$ \textbf{S\_\-SubString} (\hyperlink{structS__String}{S\_\-String} $\ast$String, int Offset, int Length)}
\label{String_8h_d9f08c3a7df7a114b92ced900f34fd12}

\end{CompactItemize}


\subsection{Detailed Description}
A library to handle C strings easily. 

\begin{Desc}
\item[Author:]Cameron Diver \end{Desc}
\begin{Desc}
\item[Version:]0.1 \end{Desc}
\hypertarget{Vector_8h_Description}{}\subsection{Description}\label{Vector_8h_Description}
A library for handling strings transparently, with this library handling memory, length and size. The functions provided will help with most things, but the underlying C string is available if the functions are not enough. The library has the advantage of being able to store anything, due to it not using null bytes as delimiters 

Definition in file \hyperlink{String_8h-source}{String.h}.

\subsection{Define Documentation}
\hypertarget{String_8h_cf8d6deb7696df87d92f7b321afee568}{
\index{String.h@{String.h}!S\_\-At@{S\_\-At}}
\index{S\_\-At@{S\_\-At}!String.h@{String.h}}
\subsubsection[{S\_\-At}]{\setlength{\rightskip}{0pt plus 5cm}\#define S\_\-At(Str, \/  At)~(char)((({\bf S\_\-String} $\ast$)Str) $\rightarrow$ String\mbox{[}At\mbox{]})}}
\label{String_8h_cf8d6deb7696df87d92f7b321afee568}


This function returns the character that is at At 

Definition at line 54 of file String.h.\hypertarget{String_8h_eb0ec9f2dbaa8a1504bee0ce980db6e1}{
\index{String.h@{String.h}!S\_\-Capitalise@{S\_\-Capitalise}}
\index{S\_\-Capitalise@{S\_\-Capitalise}!String.h@{String.h}}
\subsubsection[{S\_\-Capitalise}]{\setlength{\rightskip}{0pt plus 5cm}\#define S\_\-Capitalise(Str)}}
\label{String_8h_eb0ec9f2dbaa8a1504bee0ce980db6e1}


\textbf{Value:}

\begin{Code}\begin{verbatim}do{if(((S_String *)Str)->Length>0&&islower(((S_String *)Str)->String[0]))\
                                    {((S_String *)Str)->String[0]=toupper(((S_String *)Str)->String[0]);}}while(0)
\end{verbatim}
\end{Code}
This function capitalises the character at the start of the string, that is if it can be capitalised 

Definition at line 56 of file String.h.\hypertarget{String_8h_0563d6c3e3ffc508c38137a212cdcc38}{
\index{String.h@{String.h}!S\_\-GetCString@{S\_\-GetCString}}
\index{S\_\-GetCString@{S\_\-GetCString}!String.h@{String.h}}
\subsubsection[{S\_\-GetCString}]{\setlength{\rightskip}{0pt plus 5cm}\#define S\_\-GetCString(Str)~(((char $\ast$)(({\bf S\_\-String} $\ast$)Str) $\rightarrow$ String))}}
\label{String_8h_0563d6c3e3ffc508c38137a212cdcc38}


Returns the underlying C string. Note that this is not null byte delimited. 

Definition at line 44 of file String.h.\hypertarget{String_8h_1bf2e5f197b170b1c56d22bda138dd41}{
\index{String.h@{String.h}!S\_\-GetSize@{S\_\-GetSize}}
\index{S\_\-GetSize@{S\_\-GetSize}!String.h@{String.h}}
\subsubsection[{S\_\-GetSize}]{\setlength{\rightskip}{0pt plus 5cm}\#define S\_\-GetSize(Str)~((({\bf S\_\-String} $\ast$)Str) $\rightarrow$ Size)}}
\label{String_8h_1bf2e5f197b170b1c56d22bda138dd41}


This gets the size of the String, that is how much it can contain before needing to be reallocated 

Definition at line 52 of file String.h.\hypertarget{String_8h_c0d7369f7433d6984f0b888fefd524a9}{
\index{String.h@{String.h}!S\_\-GetStringLength@{S\_\-GetStringLength}}
\index{S\_\-GetStringLength@{S\_\-GetStringLength}!String.h@{String.h}}
\subsubsection[{S\_\-GetStringLength}]{\setlength{\rightskip}{0pt plus 5cm}\#define S\_\-GetStringLength(String)~(((({\bf S\_\-String}$\ast$)String) $\rightarrow$ Length))}}
\label{String_8h_c0d7369f7433d6984f0b888fefd524a9}


Returns the length of the string. Note that the length of the string is different to the size. 

Definition at line 46 of file String.h.\hypertarget{String_8h_76fecf032417987ff2a52d09cadc74fe}{
\index{String.h@{String.h}!S\_\-Print@{S\_\-Print}}
\index{S\_\-Print@{S\_\-Print}!String.h@{String.h}}
\subsubsection[{S\_\-Print}]{\setlength{\rightskip}{0pt plus 5cm}\#define S\_\-Print(Str)~(printf(\char`\"{}\%s\char`\"{}, (((S\_\-String $\ast$)Str) $\rightarrow$ String)))}}
\label{String_8h_76fecf032417987ff2a52d09cadc74fe}


Prints the string. This should only be used when the string is certain to not contain any null bytes. If the string might contain null bytes, use S\_\-PrintSafe. 

Definition at line 50 of file String.h.

\subsection{Function Documentation}
\hypertarget{String_8h_2f497e9820c3ef3262b2b79c67de1e30}{
\index{String.h@{String.h}!S\_\-AppendString@{S\_\-AppendString}}
\index{S\_\-AppendString@{S\_\-AppendString}!String.h@{String.h}}
\subsubsection[{S\_\-AppendString}]{\setlength{\rightskip}{0pt plus 5cm}int S\_\-AppendString ({\bf S\_\-String} $\ast$ {\em String}, \/  char $\ast$ {\em Str})}}
\label{String_8h_2f497e9820c3ef3262b2b79c67de1e30}


This function will append a string onto the given \hyperlink{structS__String}{S\_\-String} object \begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em String}]The \hyperlink{structS__String}{S\_\-String} object with which to append another string \item[{\em Str}]The string to append \end{description}
\end{Desc}
\begin{Desc}
\item[Returns:]This function will return 0 on success, or -1 on error \end{Desc}
\hypertarget{StringConvert_8c_Note}{}\subsection{Note}\label{StringConvert_8c_Note}
This function will allocate more memory for the \hyperlink{structS__String}{S\_\-String} object if it has to. Where possible, it is a lot faster to use S\_\-Prepend$\ast$ than the S\_\-Append$\ast$ functions 

Definition at line 130 of file String.c.

\begin{Code}\begin{verbatim}131 {
132     int Length = strlen(Str);
133     /*char *TempPointer = realloc(String->String, sizeof(String->String)*(String->Length+Length));
134     if(TempPointer == NULL)
135         return -1;
136     String->String = TempPointer;*/
137     if(StrCheckRealloc(String, sizeof(String->String)*(String->Length+Length)) == -1)
138         return -1;
139     /* Increase the string pointer by the length of the string, and then append the new string to that pointer */
140     memcpy(String->String + String->Length-1, Str, Length);
141     String->Length += Length;
142     return 0;
143 }
\end{verbatim}
\end{Code}


\hypertarget{String_8h_25e94b51b04d73fdb76771ea78af38eb}{
\index{String.h@{String.h}!S\_\-AppendStringS@{S\_\-AppendStringS}}
\index{S\_\-AppendStringS@{S\_\-AppendStringS}!String.h@{String.h}}
\subsubsection[{S\_\-AppendStringS}]{\setlength{\rightskip}{0pt plus 5cm}int S\_\-AppendStringS ({\bf S\_\-String} $\ast$ {\em Str}, \/  {\bf S\_\-String} $\ast$ {\em AppendString})}}
\label{String_8h_25e94b51b04d73fdb76771ea78af38eb}


This function will append one \hyperlink{structS__String}{S\_\-String} object onto another \hyperlink{structS__String}{S\_\-String} object \begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em String}]The \hyperlink{structS__String}{S\_\-String} object with which to append another string \item[{\em AppendString}]The \hyperlink{structS__String}{S\_\-String} object to append \end{description}
\end{Desc}
\begin{Desc}
\item[Returns:]This function will return 0 on success, or -1 on error \end{Desc}
\hypertarget{StringConvert_8c_Note}{}\subsection{Note}\label{StringConvert_8c_Note}
This function will allocate more memory for the \hyperlink{structS__String}{S\_\-String} object if it has to. Where possible, it is a lot faster to use S\_\-Prepend$\ast$ than the S\_\-Append$\ast$ functions 

Definition at line 145 of file String.c.

\begin{Code}\begin{verbatim}146 {
147     /*char *TempPointer = realloc(Str->String, sizeof(Str->String)*(Str->Length+AppendString->Length));
148     if(TempPointer == NULL)
149         return -1;
150     Str->String = TempPointer;*/
151     if(StrCheckRealloc(Str, sizeof(Str->String)*(Str->Length+AppendString->Length)) == -1)
152         return -1;
153     memcpy(Str->String + Str->Length, AppendString->String, AppendString->Length);
154     return 0;
155 }
\end{verbatim}
\end{Code}


\hypertarget{String_8h_e90bcfd70b2bf03e0c4c440dd3c06155}{
\index{String.h@{String.h}!S\_\-AppendStringSafe@{S\_\-AppendStringSafe}}
\index{S\_\-AppendStringSafe@{S\_\-AppendStringSafe}!String.h@{String.h}}
\subsubsection[{S\_\-AppendStringSafe}]{\setlength{\rightskip}{0pt plus 5cm}int S\_\-AppendStringSafe ({\bf S\_\-String} $\ast$ {\em String}, \/  char $\ast$ {\em Str}, \/  int {\em Length})}}
\label{String_8h_e90bcfd70b2bf03e0c4c440dd3c06155}


This function will append a string onto the given \hyperlink{structS__String}{S\_\-String} object. This function will copy with a specified length \begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em String}]The \hyperlink{structS__String}{S\_\-String} object with which to append another string \item[{\em Str}]The string to append \item[{\em Length}]The length of the string to be appended. \end{description}
\end{Desc}
\begin{Desc}
\item[Returns:]This function will return 0 on success, or -1 on error \end{Desc}
\hypertarget{StringConvert_8c_Note}{}\subsection{Note}\label{StringConvert_8c_Note}
This function will allocate more memory for the \hyperlink{structS__String}{S\_\-String} object if it has to. Where possible, it is a lot faster to use S\_\-Prepend$\ast$ than the S\_\-Append$\ast$ functions. 

Definition at line 156 of file String.c.

\begin{Code}\begin{verbatim}157 {
158     /*char *TempPointer = realloc(String->String, sizeof(String->String)*(String->Length+Length));
159     if(TempPointer == NULL)
160         return -1;
161     String->String = TempPointer;*/
162     if(StrCheckRealloc(String, sizeof(String->String)*(String->Length+Length)) == -1)
163         return -1;
164     memcpy(String->String + String->Length, Str, Length);
165     return 0; 
166 }
\end{verbatim}
\end{Code}


\hypertarget{String_8h_fb479750a3d46abcbe6687f10cf48d93}{
\index{String.h@{String.h}!S\_\-FreeString@{S\_\-FreeString}}
\index{S\_\-FreeString@{S\_\-FreeString}!String.h@{String.h}}
\subsubsection[{S\_\-FreeString}]{\setlength{\rightskip}{0pt plus 5cm}void S\_\-FreeString ({\bf S\_\-String} $\ast$ {\em String})}}
\label{String_8h_fb479750a3d46abcbe6687f10cf48d93}


This function will clear all of the resources that are being used by the \hyperlink{structS__String}{S\_\-String} \begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em String}]The pointer to a \hyperlink{structS__String}{S\_\-String} which will be freed \end{description}
\end{Desc}
\hypertarget{StringConvert_8c_Note}{}\subsection{Note}\label{StringConvert_8c_Note}
This function can cause a double free or memory corruption if an invalid pointer is passed to it 

Definition at line 62 of file String.c.

\begin{Code}\begin{verbatim}63 {
64     /* Free all of the data that is being used by the S_String object */
65     free(String->String);
66     free(String);
67 }
\end{verbatim}
\end{Code}


\hypertarget{String_8h_e350e958b6a6cf2295e9df849c90b5bd}{
\index{String.h@{String.h}!S\_\-InsertString@{S\_\-InsertString}}
\index{S\_\-InsertString@{S\_\-InsertString}!String.h@{String.h}}
\subsubsection[{S\_\-InsertString}]{\setlength{\rightskip}{0pt plus 5cm}int S\_\-InsertString ({\bf S\_\-String} $\ast$ {\em String}, \/  int {\em Offset}, \/  char $\ast$ {\em Str})}}
\label{String_8h_e350e958b6a6cf2295e9df849c90b5bd}


This function will insert a string into a \hyperlink{structS__String}{S\_\-String} object.

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em String}]The \hyperlink{structS__String}{S\_\-String} object in which to insert the string \item[{\em Offset}]The offset to position the string \item[{\em Str}]The string to insert \end{description}
\end{Desc}
\begin{Desc}
\item[Returns:]This function returns 0 on success, or -1 on error\end{Desc}
\hypertarget{StringConvert_8c_Note}{}\subsection{Note}\label{StringConvert_8c_Note}
This function will allocate more memory for the \hyperlink{structS__String}{S\_\-String} object if it has to.

The safe functions have been provided for strings that may contain null bytes. 

Definition at line 168 of file String.c.

\begin{Code}\begin{verbatim}169 {
170     /*FIXME:
171         This function could be changed to not use any Temp arrays,
172         and just relying on the optomisations of the C libraries
173         memmove and memcpy
174     */
175     if(Offset > 0)
176     {
177         /* Make enough space for the original string, then copy over the original string in two sections */
178         char Temp1[Offset];
179         memcpy(Temp1, String->String, Offset);
180         char Temp2[String->Length-Offset];
181         memcpy(Temp2, String->String+Offset, String->Length - Offset+1);
182         /*void *TempPointer = realloc(String->String, sizeof(String->String)*String->Length+strlen(Str));
183         if(TempPointer == NULL)
184             return -1;
185         String->String = TempPointer;*/
186         if(StrCheckRealloc(String, sizeof(String->String)*(String->Length+strlen(Str))) == -1)
187             return -1;
188         /* Put all the strings back, in the (new) correct order */
189         memcpy(String->String, Temp1, Offset);
190         memcpy(String->String + Offset, Str, strlen(Str));
191         memcpy(String->String + Offset + strlen(Str), Temp2, String->Length-Offset);
192         String->Length += strlen(Str);
193         return 0;
194     }   
195     else
196     {
197         return S_PrependString(String, Str);
198     }
199 }
\end{verbatim}
\end{Code}


\hypertarget{String_8h_4b914eef05daab599aaf9e0cb7e1fd8b}{
\index{String.h@{String.h}!S\_\-InsertStringS@{S\_\-InsertStringS}}
\index{S\_\-InsertStringS@{S\_\-InsertStringS}!String.h@{String.h}}
\subsubsection[{S\_\-InsertStringS}]{\setlength{\rightskip}{0pt plus 5cm}int S\_\-InsertStringS ({\bf S\_\-String} $\ast$ {\em Str}, \/  int {\em Offset}, \/  {\bf S\_\-String} $\ast$ {\em InsertString})}}
\label{String_8h_4b914eef05daab599aaf9e0cb7e1fd8b}


This function will insert one \hyperlink{structS__String}{S\_\-String} into another \hyperlink{structS__String}{S\_\-String} object \begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em String}]The \hyperlink{structS__String}{S\_\-String} object in which to insert the string \item[{\em Offset}]The offset to position the string \item[{\em Str}]The \hyperlink{structS__String}{S\_\-String} to insert \end{description}
\end{Desc}
\begin{Desc}
\item[Returns:]This function returns 0 on success, or -1 on error \end{Desc}
\hypertarget{StringConvert_8c_Note}{}\subsection{Note}\label{StringConvert_8c_Note}
This function will allocate more memory for the \hyperlink{structS__String}{S\_\-String} object if it has to. 

Definition at line 200 of file String.c.

\begin{Code}\begin{verbatim}201 {
202     if(Offset > 0)
203     {
204         char Temp1[Offset];
205         memcpy(Temp1, String->String, Offset);
206         char Temp2[String->Length-Offset];
207         memcpy(Temp2, String->String+Offset, String->Length - Offset+1);
208         /*void *TempPointer = realloc(String->String, sizeof(String->String)*String->Length+InsertString->Length);
209         if(TempPointer == NULL)
210             return -1;
211         String->String = TempPointer;*/
212         if(StrCheckRealloc(String, sizeof(String->String)*(String->Length+InsertString->Length)) == -1)
213             return -1;
214         memcpy(String->String, Temp1, Offset);
215         memcpy(String->String + Offset, InsertString->String, InsertString->Length);
216         memcpy(String->String + Offset + InsertString->Length, Temp2, String->Length-Offset);
217         String->Length += InsertString->Length;
218         return 0;
219     }
220     else
221     {
222         return S_PrependStringS(String, InsertString);
223     }
224 }
\end{verbatim}
\end{Code}


\hypertarget{String_8h_2e7248a6c3ab64367a1ebe42945e9357}{
\index{String.h@{String.h}!S\_\-InsertStringSafe@{S\_\-InsertStringSafe}}
\index{S\_\-InsertStringSafe@{S\_\-InsertStringSafe}!String.h@{String.h}}
\subsubsection[{S\_\-InsertStringSafe}]{\setlength{\rightskip}{0pt plus 5cm}int S\_\-InsertStringSafe ({\bf S\_\-String} $\ast$ {\em String}, \/  int {\em Offset}, \/  char $\ast$ {\em Str}, \/  int {\em Length})}}
\label{String_8h_2e7248a6c3ab64367a1ebe42945e9357}


This function will insert a string into a \hyperlink{structS__String}{S\_\-String} object, with a specified length \begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em String}]The \hyperlink{structS__String}{S\_\-String} object in which to insert the string \item[{\em Offset}]The offset to position the string \item[{\em Str}]The string to insert \item[{\em Length}]The length of the string to insert \end{description}
\end{Desc}
\begin{Desc}
\item[Returns:]This function returns 0 on success, or -1 on error \end{Desc}
\hypertarget{StringConvert_8c_Note}{}\subsection{Note}\label{StringConvert_8c_Note}
This function will allocate more memory for the \hyperlink{structS__String}{S\_\-String} object if it has to. The safe functions have been provided for handling strings that contain null bytes. 

Definition at line 226 of file String.c.

\begin{Code}\begin{verbatim}227 {
228     if(Offset > 0)
229     {
230         char Temp1[Offset];
231         char Temp2[String->Length-Offset];
232         memcpy(Temp1, String->String, Offset);
233         memcpy(Temp2, String->String+Offset, String->Length - Offset+1);
234         if(StrCheckRealloc(String, sizeof(String->String)*(String->Length+Length)) == -1)
235             return -1;
236         memcpy(String->String, Temp1, Offset);
237         memcpy(String->String + Offset, Str, Length);
238         memcpy(String->String + Offset + Length, Temp2, String->Length - Offset);
239         String->Length += Length;
240         return 0;
241     }
242     else
243     {
244         return S_PrependStringSafe(String, Str, Length);
245     }
246 }
\end{verbatim}
\end{Code}


\hypertarget{String_8h_7dc0082e7024328d845f6303022d3a3d}{
\index{String.h@{String.h}!S\_\-NewString@{S\_\-NewString}}
\index{S\_\-NewString@{S\_\-NewString}!String.h@{String.h}}
\subsubsection[{S\_\-NewString}]{\setlength{\rightskip}{0pt plus 5cm}{\bf S\_\-String}$\ast$ S\_\-NewString (char $\ast$ {\em String})}}
\label{String_8h_7dc0082e7024328d845f6303022d3a3d}


This function creates a new string and returns a pointer to it, and sets that strings value to the value passed with String \begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em String}]A string with which to fill the new \hyperlink{structS__String}{S\_\-String} with \end{description}
\end{Desc}
\begin{Desc}
\item[Returns:]This function will return NULL on error, else it will return a pointer to a new \hyperlink{structS__String}{S\_\-String} \end{Desc}


Definition at line 30 of file String.c.

\begin{Code}\begin{verbatim}31 {
32     /* Allocate a new S_String object on the heap,
33         check the allocation, and return the object (or NULL)
34     */
35     S_String *Ret = malloc(sizeof(Ret));
36     if(Ret == NULL)
37         return NULL;
38     Ret->String = malloc(sizeof(Ret->String)*strlen(String));
39     Ret->Size = strlen(String);
40     if(Ret->String == NULL)
41         return NULL;
42     if(S_SetString(Ret, String) == -1)
43         return NULL;
44     Ret->Length = strlen(Ret->String);
45     return Ret;
46 }
\end{verbatim}
\end{Code}


\hypertarget{String_8h_302e8ec221992e858d038c99cfd85d96}{
\index{String.h@{String.h}!S\_\-NewStringSafe@{S\_\-NewStringSafe}}
\index{S\_\-NewStringSafe@{S\_\-NewStringSafe}!String.h@{String.h}}
\subsubsection[{S\_\-NewStringSafe}]{\setlength{\rightskip}{0pt plus 5cm}{\bf S\_\-String}$\ast$ S\_\-NewStringSafe (char $\ast$ {\em String}, \/  int {\em Length})}}
\label{String_8h_302e8ec221992e858d038c99cfd85d96}


This function is very similar to S\_\-NewString, but this one accepts another parameter of length, which is used to allocate the string, and copy over the data. \begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em String}]A string with which to fill the new \hyperlink{structS__String}{S\_\-String} with \item[{\em Length}]The length of the string that is used to create the new \hyperlink{structS__String}{S\_\-String} \end{description}
\end{Desc}
\begin{Desc}
\item[Returns:]A pointer to a new \hyperlink{structS__String}{S\_\-String} object, or NULL on error \end{Desc}


Definition at line 47 of file String.c.

\begin{Code}\begin{verbatim}48 {
49     S_String *Ret = malloc(sizeof(Ret));
50     if(Ret == NULL)
51         return NULL;
52     Ret->String = malloc(sizeof(Ret->String)*Length);
53     if(Ret->String == NULL)
54         return NULL;
55     if(S_SetStringSafe(Ret, String, Length) == -1)
56         return NULL;
57     Ret->Length = Length;
58     Ret->Size = Length;
59     return Ret;
60 }
\end{verbatim}
\end{Code}


\hypertarget{String_8h_2033f8307c67c28af946922073dc46bf}{
\index{String.h@{String.h}!S\_\-PadFront@{S\_\-PadFront}}
\index{S\_\-PadFront@{S\_\-PadFront}!String.h@{String.h}}
\subsubsection[{S\_\-PadFront}]{\setlength{\rightskip}{0pt plus 5cm}int S\_\-PadFront ({\bf S\_\-String} $\ast$ {\em Str}, \/  int {\em Length}, \/  char {\em PadChar})}}
\label{String_8h_2033f8307c67c28af946922073dc46bf}


This function pads the front of a string until the desired length is reached \begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em Str}]The string to pad \item[{\em Length}]The length to pad the string to \item[{\em PadChar}]The character used to pad the string \end{description}
\end{Desc}
\begin{Desc}
\item[Returns:]This function will return 0 on success, or -1 on failure. \end{Desc}
\hypertarget{String_8h_Notes}{}\subsection{Notes}\label{String_8h_Notes}
This function will try to allocate more memory for the \hyperlink{structS__String}{S\_\-String} object if neccesary. 

Definition at line 395 of file String.c.

\begin{Code}\begin{verbatim}396 {
397     if(Str->Length >= Length) /* The string does not need to be padded... */
398         return 0;
399     if(StrCheckRealloc(Str, Length) == -1)
400         return -1;
401     char Temp[Length-Str->Length];
402     /* Was using memset here, until IllegalInstruction exceptions were being thrown. FML */
403     int Index = 0;
404     while(Index < Length - Str->Length)
405         Temp[Index++] = PadChar;
406     return S_PrependStringSafe(Str, Temp, Length-Str->Length);
407 }
\end{verbatim}
\end{Code}


\hypertarget{String_8h_feffcc4d51463b7d5e0ee8f909281c20}{
\index{String.h@{String.h}!S\_\-PrependString@{S\_\-PrependString}}
\index{S\_\-PrependString@{S\_\-PrependString}!String.h@{String.h}}
\subsubsection[{S\_\-PrependString}]{\setlength{\rightskip}{0pt plus 5cm}int S\_\-PrependString ({\bf S\_\-String} $\ast$ {\em String}, \/  char $\ast$ {\em Str})}}
\label{String_8h_feffcc4d51463b7d5e0ee8f909281c20}


This function prepends a string onto a \hyperlink{structS__String}{S\_\-String} Object \begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em String}]The \hyperlink{structS__String}{S\_\-String} object with which to prepend the string \item[{\em Str}]The string to prepend \end{description}
\end{Desc}
\begin{Desc}
\item[Returns:]This function returns 0 on success, or -1 on error \end{Desc}
\hypertarget{StringConvert_8c_Note}{}\subsection{Note}\label{StringConvert_8c_Note}
This function will allocate more memory for the \hyperlink{structS__String}{S\_\-String} object if it has to. 

Definition at line 248 of file String.c.

\begin{Code}\begin{verbatim}249 {
250     /* FIXME:
251         The prepend functions are quite slow, due to the
252         shifting of the whole string by an arbritary amount.
253         Optomisation ideas welcome
254     */
255     int Size =strlen(Str);
256     if(StrCheckRealloc(String, sizeof(String->String)*Size+String->Length) == -1)
257         return -1;
258     /* Move the string that is already present to an offset of the length of the prepended string*/
259     memmove(String->String + Size, String->String, String->Length);
260     /* Copy the prepended string into the start of the original string */
261     memcpy(String->String, Str, Size);
262     String->Length += Size;
263     return 0;
264 }
\end{verbatim}
\end{Code}


\hypertarget{String_8h_377ac91d577be4a74ff215cdf1acb1b6}{
\index{String.h@{String.h}!S\_\-PrependStringS@{S\_\-PrependStringS}}
\index{S\_\-PrependStringS@{S\_\-PrependStringS}!String.h@{String.h}}
\subsubsection[{S\_\-PrependStringS}]{\setlength{\rightskip}{0pt plus 5cm}int S\_\-PrependStringS ({\bf S\_\-String} $\ast$ {\em String}, \/  {\bf S\_\-String} $\ast$ {\em PString})}}
\label{String_8h_377ac91d577be4a74ff215cdf1acb1b6}


This function prepends one \hyperlink{structS__String}{S\_\-String} onto another \hyperlink{structS__String}{S\_\-String} Object \begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em String}]The \hyperlink{structS__String}{S\_\-String} object with which to prepend the string \item[{\em Str}]The \hyperlink{structS__String}{S\_\-String} object to prepend \end{description}
\end{Desc}
\begin{Desc}
\item[Returns:]This function returns 0 on success, or -1 on error \end{Desc}
\hypertarget{StringConvert_8c_Note}{}\subsection{Note}\label{StringConvert_8c_Note}
This function will allocate more memory for the \hyperlink{structS__String}{S\_\-String} object if it has to. 

Definition at line 265 of file String.c.

\begin{Code}\begin{verbatim}266 {
267     if(StrCheckRealloc(String, sizeof(String->String)*PString->Length+String->Length) == -1)
268         return -1;
269     memmove(String->String+PString->Length, String->String, String->Length);
270     memcpy(String->String, PString->String, PString->Length);
271     String->Length += PString->Length;
272     return 0;
273 }
\end{verbatim}
\end{Code}


\hypertarget{String_8h_f565622e62f5b2e68b3dadaa9e81357d}{
\index{String.h@{String.h}!S\_\-PrependStringSafe@{S\_\-PrependStringSafe}}
\index{S\_\-PrependStringSafe@{S\_\-PrependStringSafe}!String.h@{String.h}}
\subsubsection[{S\_\-PrependStringSafe}]{\setlength{\rightskip}{0pt plus 5cm}int S\_\-PrependStringSafe ({\bf S\_\-String} $\ast$ {\em String}, \/  char $\ast$ {\em Str}, \/  int {\em Length})}}
\label{String_8h_f565622e62f5b2e68b3dadaa9e81357d}


This function prepends a string onto a \hyperlink{structS__String}{S\_\-String} Object, with a specified length \begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em String}]The \hyperlink{structS__String}{S\_\-String} object with which to prepend the string \item[{\em Str}]The string to prepend \item[{\em Length}]The length of the string to be prepended \end{description}
\end{Desc}
\begin{Desc}
\item[Returns:]This function returns 0 on success, or -1 on error \end{Desc}
\hypertarget{StringConvert_8c_Note}{}\subsection{Note}\label{StringConvert_8c_Note}
This function will allocate more memory for the \hyperlink{structS__String}{S\_\-String} object if it has to. The safe functions have been provided for working with strings that may contain null bytes. 

Definition at line 274 of file String.c.

\begin{Code}\begin{verbatim}275 {
276     if(StrCheckRealloc(String, sizeof(String->String)*Length+String->Length) == -1)
277         return -1;
278     memmove(String->String+Length, String->String, String->Length);
279     memcpy(String->String, Str, Length);
280     String->Length += Length;
281     return 0;
282 }
\end{verbatim}
\end{Code}


\hypertarget{String_8h_dba46a32cd273e7b883a2620add35c12}{
\index{String.h@{String.h}!S\_\-PrintSafe@{S\_\-PrintSafe}}
\index{S\_\-PrintSafe@{S\_\-PrintSafe}!String.h@{String.h}}
\subsubsection[{S\_\-PrintSafe}]{\setlength{\rightskip}{0pt plus 5cm}void S\_\-PrintSafe ({\bf S\_\-String} $\ast$ {\em String})}}
\label{String_8h_dba46a32cd273e7b883a2620add35c12}


This function is provided for printing a string that may contain null bytes \begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em String}]An \hyperlink{structS__String}{S\_\-String} object which will be printed \end{description}
\end{Desc}


Definition at line 118 of file String.c.

\begin{Code}\begin{verbatim}119 {
120     /* Print the string, char by char, so that all of the string will be preserved,
121         rather than just printf running into a null byte then stopping
122     */
123     int Count;
124     for(Count = 0; Count < String->Length; ++Count)
125     {
126         printf("%c", String->String[Count]);
127     }
128 }
\end{verbatim}
\end{Code}


\hypertarget{String_8h_a18276a7c0d108c9f111888a7e5516ac}{
\index{String.h@{String.h}!S\_\-SetSize@{S\_\-SetSize}}
\index{S\_\-SetSize@{S\_\-SetSize}!String.h@{String.h}}
\subsubsection[{S\_\-SetSize}]{\setlength{\rightskip}{0pt plus 5cm}int S\_\-SetSize ({\bf S\_\-String} $\ast$ {\em String}, \/  int {\em Size})}}
\label{String_8h_a18276a7c0d108c9f111888a7e5516ac}


This function resizes (if neccesary) the given string using realloc \begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em String}]The \hyperlink{structS__String}{S\_\-String} object to resize \item[{\em Size}]The size to resize the object to \end{description}
\end{Desc}
\begin{Desc}
\item[Returns:]This function returns 0 on success, or -1 on failure. \end{Desc}
\hypertarget{StringConvert_8c_Note}{}\subsection{Note}\label{StringConvert_8c_Note}
This function may not call realloc if the current size is equal to the size requested. 

Definition at line 284 of file String.c.

\begin{Code}\begin{verbatim}285 {
286     /* Set the capacity of the string, note that this is not the same as the length of the string */
287     if(String->Size == Size)
288         return 0;
289     void *TempPointer = realloc(String->String, sizeof(String->String)*Size);
290     if(TempPointer == NULL)
291         return -1;
292     String->String = TempPointer;
293     String->Size = Size;
294     return 0;
295 }
\end{verbatim}
\end{Code}


\hypertarget{String_8h_397b9f358bf019dc5e336404c7ec5ff7}{
\index{String.h@{String.h}!S\_\-SetString@{S\_\-SetString}}
\index{S\_\-SetString@{S\_\-SetString}!String.h@{String.h}}
\subsubsection[{S\_\-SetString}]{\setlength{\rightskip}{0pt plus 5cm}int S\_\-SetString ({\bf S\_\-String} $\ast$ {\em String}, \/  char $\ast$ {\em Str})}}
\label{String_8h_397b9f358bf019dc5e336404c7ec5ff7}


This function is used to set an \hyperlink{structS__String}{S\_\-String} object to the value of Str  String The pointer to an \hyperlink{structS__String}{S\_\-String} object which will be set to the value of Str \begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em Str}]The value with which to set the \hyperlink{structS__String}{S\_\-String} object \end{description}
\end{Desc}
\begin{Desc}
\item[Returns:]This function will return 0 on success, or -1 on error \end{Desc}
\hypertarget{StringConvert_8c_Note}{}\subsection{Note}\label{StringConvert_8c_Note}
This function will allocate more memory for the \hyperlink{structS__String}{S\_\-String} object if it has to. 

Definition at line 69 of file String.c.

\begin{Code}\begin{verbatim}70 {
71     int /*Count, */Size = strlen(Str);
72     /*void *TempPointer = realloc(String->String, sizeof(String->String)*Size);
73     if(TempPointer == NULL)
74         return -1;
75     String->String = TempPointer;
76     */
77     if(StrCheckRealloc(String, sizeof(String->String)*Size) == -1)
78         return -1;
79     /*for(Count = 0; Count < Size; ++Count)
80     {
81         String->String[Count] = Str[Count];
82     }*/
83     /* Copy the string over, by now the string is guarenteed to have enough memory */
84     memcpy(String->String, Str, Size);
85     String->Length = Size;
86     return 0;
87 }
\end{verbatim}
\end{Code}


\hypertarget{String_8h_5ab90ac0b5817203509ad74809e24c81}{
\index{String.h@{String.h}!S\_\-SetStringS@{S\_\-SetStringS}}
\index{S\_\-SetStringS@{S\_\-SetStringS}!String.h@{String.h}}
\subsubsection[{S\_\-SetStringS}]{\setlength{\rightskip}{0pt plus 5cm}int S\_\-SetStringS ({\bf S\_\-String} $\ast$ {\em String}, \/  {\bf S\_\-String} $\ast$ {\em SetString})}}
\label{String_8h_5ab90ac0b5817203509ad74809e24c81}


This function is used to set an \hyperlink{structS__String}{S\_\-String} object to the value of another \hyperlink{structS__String}{S\_\-String} object \begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em String}]The pointer to \hyperlink{structS__String}{S\_\-String} object which will be set to the value of SetString \item[{\em SetString}]The pointer to another \hyperlink{structS__String}{S\_\-String} object, which will be used to set String \end{description}
\end{Desc}
\begin{Desc}
\item[Returns:]This function will return 0 on success, or -1 on error \end{Desc}
\hypertarget{StringConvert_8c_Note}{}\subsection{Note}\label{StringConvert_8c_Note}
This function will allocate more memory for the \hyperlink{structS__String}{S\_\-String} object if it has to. 

Definition at line 88 of file String.c.

\begin{Code}\begin{verbatim}89 {
90     /*char *TempPointer = realloc(String->String, sizeof(String->String)*SetString->Length);
91     if(TempPointer == NULL)
92         return -1;
93     String->String = TempPointer;*/
94     if(StrCheckRealloc(String, sizeof(String->String)*SetString->Length) == -1)
95         return -1;
96     memcpy(String->String, SetString->String, SetString->Length);
97     String->Length = SetString->Length;
98     return 0;
99 }
\end{verbatim}
\end{Code}


\hypertarget{String_8h_7e2d8dace30f0de44d7b27671477a989}{
\index{String.h@{String.h}!S\_\-SetStringSafe@{S\_\-SetStringSafe}}
\index{S\_\-SetStringSafe@{S\_\-SetStringSafe}!String.h@{String.h}}
\subsubsection[{S\_\-SetStringSafe}]{\setlength{\rightskip}{0pt plus 5cm}int S\_\-SetStringSafe ({\bf S\_\-String} $\ast$ {\em String}, \/  char $\ast$ {\em Str}, \/  int {\em Length})}}
\label{String_8h_7e2d8dace30f0de44d7b27671477a989}


This function is used to set an \hyperlink{structS__String}{S\_\-String} object to the value of another \hyperlink{structS__String}{S\_\-String} object \begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em String}]The \hyperlink{structS__String}{S\_\-String} object which will have it's value changed \item[{\em Str}]The string that will be copied into String \item[{\em Length}]The length of the string Str, or however much of that string is to be used \end{description}
\end{Desc}
\begin{Desc}
\item[Returns:]This function will return 0 on success, or -1 on error \end{Desc}
\hypertarget{StringConvert_8c_Note}{}\subsection{Note}\label{StringConvert_8c_Note}
This function will allocate more memory for the \hyperlink{structS__String}{S\_\-String} object if it has to. The safe functions have been provided for strings that may contain null bytes. 

Definition at line 100 of file String.c.

\begin{Code}\begin{verbatim}101 {
102     /*int Count;*/
103     /*char *TempPointer = realloc(String->String, sizeof(String->String)*Length);
104     if(TempPointer == NULL)
105         return -1;
106     String->String = TempPointer;*/
107     if(StrCheckRealloc(String, sizeof(String->String)*Length) == -1)
108         return -1;
109     /*for(Count = 0; Count < Length; ++Count)
110     {
111         String->String[Count] = Str[Count];
112     }*/
113     memcpy(String->String, Str, Length);
114     String->Length = Length;
115     return 0;
116 }
\end{verbatim}
\end{Code}


\hypertarget{String_8h_c1a935af70a79d84f2358d693a669afe}{
\index{String.h@{String.h}!S\_\-StringReverse@{S\_\-StringReverse}}
\index{S\_\-StringReverse@{S\_\-StringReverse}!String.h@{String.h}}
\subsubsection[{S\_\-StringReverse}]{\setlength{\rightskip}{0pt plus 5cm}void S\_\-StringReverse ({\bf S\_\-String} $\ast$ {\em String})}}
\label{String_8h_c1a935af70a79d84f2358d693a669afe}


This function reverses the given string \begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em String}]The string to reverse \end{description}
\end{Desc}
\hypertarget{StringConvert_8c_Note}{}\subsection{Note}\label{StringConvert_8c_Note}
This function does the reversing in-place. 

Definition at line 303 of file String.c.

\begin{Code}\begin{verbatim}304 {
305     char *Front, *Back;
306     for(Front = String->String, Back = String->String + String->Length -1;
307         Front < Back;
308         ++Front, --Back)
309     {   
310         char Tmp;
311         Tmp = *Front;
312         *Front = *Back;
313         *Back = Tmp;
314     }
315 }
\end{verbatim}
\end{Code}


\hypertarget{String_8h_b493e8c1abbeff2ebcb678c99e558dae}{
\index{String.h@{String.h}!S\_\-Strip@{S\_\-Strip}}
\index{S\_\-Strip@{S\_\-Strip}!String.h@{String.h}}
\subsubsection[{S\_\-Strip}]{\setlength{\rightskip}{0pt plus 5cm}void S\_\-Strip ({\bf S\_\-String} $\ast$ {\em String})}}
\label{String_8h_b493e8c1abbeff2ebcb678c99e558dae}


This function strips whitespace from the front and end of a string \begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em String}]The string to strip \end{description}
\end{Desc}
\hypertarget{StringConvert_8c_Note}{}\subsection{Note}\label{StringConvert_8c_Note}
This function does the stripping in-place. If the length of the string changes in this function, it is updated 

Definition at line 366 of file String.c.

\begin{Code}\begin{verbatim}367 {
368     /* Remove all of the whitespace from the start and end of the string */
369     int ResultingLength = String->Length, Index, StartOffset = 0;
370     for(Index = 0; Index < String->Length; ++Index)
371     {
372         if(String->String[Index] == 10 || String->String[Index] == 13 ||
373         String->String[Index] == 32 || String->String[Index] == 9)
374         {
375             ++StartOffset;
376             --ResultingLength;
377         }
378         else
379             break;
380     }
381     for(Index = String->Length - 1; Index >= 0; --Index)
382     {
383         if(String->String[Index] == 10 || String->String[Index] == 13 ||
384         String->String[Index] == 32 || String->String[Index] == 9)
385         {
386             --ResultingLength;
387         }
388         else
389             break;
390     }
391     memmove(String->String, String->String+StartOffset, ResultingLength);
392     String->Length = ResultingLength;
393 }
\end{verbatim}
\end{Code}


\hypertarget{String_8h_dcdee4e175553bec6a8e6ebea86d952b}{
\index{String.h@{String.h}!S\_\-ToDouble@{S\_\-ToDouble}}
\index{S\_\-ToDouble@{S\_\-ToDouble}!String.h@{String.h}}
\subsubsection[{S\_\-ToDouble}]{\setlength{\rightskip}{0pt plus 5cm}double S\_\-ToDouble ({\bf S\_\-String} $\ast$ {\em String})}}
\label{String_8h_dcdee4e175553bec6a8e6ebea86d952b}


This function converts a given string into a double precision floating point number, then returns it. \begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em String}]The string to be converted. \end{description}
\end{Desc}
\begin{Desc}
\item[Returns:]A double version of the given string \end{Desc}
\hypertarget{StringConvert_8c_Note}{}\subsection{Note}\label{StringConvert_8c_Note}
This function assumes that the given string contains a number in base 10.

All character that are not 0-9 are ignored, and the function continues as if they were never there.

This function checks for signed-ness at the start of the number. Note that (excluding whitespace) the sign has to be the first thing in the string.

If the function fails, it will return 0.0. 

Definition at line 16 of file StringConvert.c.

\begin{Code}\begin{verbatim}17 {
18     double Result;
19     Result = (double)S_ToLong(String);
20     /* Find the position of the decimal place */
21     int Position = S_FindFirstC(String, '.');
22     if(Position == -1)
23         return Result;
24     /* Get the fractional part's string */
25     S_String *FractionalPart = S_SubString(String, Position+1, String->Length-(Position+1));
26     if(FractionalPart == NULL)
27         return 0;
28     S_Strip(FractionalPart);
29     /* Work out how much to divide the number by */
30     int Divide = (int)pow(10.0, S_GetStringLength(FractionalPart));
31     /* Get the fractional part, make it fractional, and add it to the result */
32     double NumericFractionalPart = S_ToLong(FractionalPart);
33     NumericFractionalPart/=Divide;
34     Result += NumericFractionalPart;
35     S_FreeString(FractionalPart);
36     return Result;
37 }
\end{verbatim}
\end{Code}




Here is the caller graph for this function:\nopagebreak
\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=56pt]{String_8h_dcdee4e175553bec6a8e6ebea86d952b_icgraph}
\end{center}
\end{figure}
\hypertarget{String_8h_ec9f3e49d886b5bb88dd74d378466ee7}{
\index{String.h@{String.h}!S\_\-ToInt@{S\_\-ToInt}}
\index{S\_\-ToInt@{S\_\-ToInt}!String.h@{String.h}}
\subsubsection[{S\_\-ToInt}]{\setlength{\rightskip}{0pt plus 5cm}int S\_\-ToInt ({\bf S\_\-String} $\ast$ {\em String})}}
\label{String_8h_ec9f3e49d886b5bb88dd74d378466ee7}


This function converts the given string to an integer and returns it. \begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em String}]The string to convert to an integer \end{description}
\end{Desc}
\begin{Desc}
\item[Returns:]The integer created from the string \end{Desc}
\hypertarget{StringConvert_8c_Note}{}\subsection{Note}\label{StringConvert_8c_Note}
This function assumes that the given string contains a number in base 10.

All character that are not 0-9 are ignored, and the function continues as if they were never there.

This function checks for signed-ness at the start of the number. Note that (excluding whitespace) the sign has to be the first thing in the string.

This functions create signed integers.

The function does not attempt to round any fractions, it just converts the elements before the decimal point.

If the function fails, it will return 0. 

Definition at line 5 of file StringConvert.c.

\begin{Code}\begin{verbatim}6 {
7     return (int)S_ToLong(String);
8 }
\end{verbatim}
\end{Code}




Here is the caller graph for this function:\nopagebreak
\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=47pt]{String_8h_ec9f3e49d886b5bb88dd74d378466ee7_icgraph}
\end{center}
\end{figure}
\hypertarget{String_8h_06727de884a78f7eefdbd8c8c5e0f3ea}{
\index{String.h@{String.h}!S\_\-ToLong@{S\_\-ToLong}}
\index{S\_\-ToLong@{S\_\-ToLong}!String.h@{String.h}}
\subsubsection[{S\_\-ToLong}]{\setlength{\rightskip}{0pt plus 5cm}long S\_\-ToLong ({\bf S\_\-String} $\ast$ {\em String})}}
\label{String_8h_06727de884a78f7eefdbd8c8c5e0f3ea}


This function converts a given string into a long integer, then returns it. \begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em String}]The string to be converted. \end{description}
\end{Desc}
\begin{Desc}
\item[Returns:]A long version of the given string \end{Desc}
\hypertarget{StringConvert_8c_Note}{}\subsection{Note}\label{StringConvert_8c_Note}
This function assumes that the given string contains a number in base 10.

All character that are not 0-9 are ignored, and the function continues as if they were never there.

This function checks for signed-ness at the start of the number. Note that (excluding whitespace) the sign has to be the first thing in the string.

The function does not attempt to round any fractions, it just converts the elements before the decimal point.

This functions create signed integers.

If the function fails, it will return 0. 

Definition at line 39 of file StringConvert.c.

\begin{Code}\begin{verbatim}40 {
41     /* Create a new string and strip the whitespace (only leading and trailing) */
42     S_String *TempString = S_NewStringSafe(String->String, String->Length);
43     if(TempString == NULL)
44         return 0;
45     S_Strip(TempString);
46     int Index = 0, Order, PointPos, IsNegative = 0, ApparentLength = 0, LengthTo = TempString->Length;
47     long Result = 0;
48     /* Check for signed-ness on the integer */
49     if(TempString->String[0] == '-')
50     {
51         Index = 1;
52         --ApparentLength;
53         IsNegative = 1;
54     }
55     else if(TempString->String[0] == '+')
56     {
57         Index = 1;
58         --ApparentLength;
59     }
60     /* Check if the string has a decimal point */
61     if((PointPos = S_FindFirstC(TempString, '.')) != -1)
62         LengthTo = PointPos;
63     ApparentLength += LengthTo;
64     /* Order is which 'column' the number is in */
65     Order = (int)pow(10, ApparentLength - 1);
66     while(Index < LengthTo)
67     {
68         if(isdigit(TempString->String[Index]))
69         {
70             long Diff = GetCharAsInt(TempString->String[Index])*Order;
71             Result += (IsNegative ? -Diff : Diff);
72             Order /= 10; /* Only reduce the order when a number is present.
73                             This allows for things like ',' and ' ' to be present in the strings */
74         }
75         ++Index;
76     }
77     S_FreeString(TempString);
78     return Result;
79 }
\end{verbatim}
\end{Code}




Here is the caller graph for this function:\nopagebreak
\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=104pt]{String_8h_06727de884a78f7eefdbd8c8c5e0f3ea_icgraph}
\end{center}
\end{figure}
\hypertarget{String_8h_251e3dc54d4e92739f21cc1f2a9c39d4}{
\index{String.h@{String.h}!S\_\-ToUpper@{S\_\-ToUpper}}
\index{S\_\-ToUpper@{S\_\-ToUpper}!String.h@{String.h}}
\subsubsection[{S\_\-ToUpper}]{\setlength{\rightskip}{0pt plus 5cm}void S\_\-ToUpper ({\bf S\_\-String} $\ast$ {\em String})}}
\label{String_8h_251e3dc54d4e92739f21cc1f2a9c39d4}


This function converts all of the characters in the string to uppercase \begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em String}]The string to convert to uppercase \end{description}
\end{Desc}
\hypertarget{StringConvert_8c_Note}{}\subsection{Note}\label{StringConvert_8c_Note}
This function does the converting in-place 

Definition at line 359 of file String.c.

\begin{Code}\begin{verbatim}360 {
361     int Count;
362     for(Count = 0; Count < String->Length; ++Count)
363         if(islower(String->String[Count]))String->String[Count] = toupper(String->String[Count]);
364 }
\end{verbatim}
\end{Code}


